package com.gps.funnymath.abstractItems;

import com.gps.funnymath.concreteItems.ConcreteStaticText;
import com.gps.funnymath.concreteItems.ConcreteToken;

public class AbstractStaticText implements AbstractToken {

	String text;
	ConcreteToken lastConcreteToken;
	
	public AbstractStaticText(String text){
		this.text = text;
		lastConcreteToken = null;
	}
	
	@Override
	public ConcreteToken instantiate() {
		return new ConcreteStaticText(text);
	}
	
	@Override
	public ConcreteToken getLastInstantiation() {
		return lastConcreteToken;
	}
	
	@Override
	public ConcreteToken getConcreteToken() {
		if(lastConcreteToken != null)
			return lastConcreteToken;

		return instantiate();
	}
	
	@Override
	public void clearInstantiationReferences() {
		lastConcreteToken = null;
	}

}
